package org.apache.flink.connector.jdbc.dialect;

import java.util.Optional;

/**
 * @ClassName ImpalaDialect @Deacription TODO @Author wushumin @Date 2021-08-05 18:05 @Version 1.0
 */
public class ImpalaDialect extends MySQLDialect {
    private static final int MAX_TIMESTAMP_PRECISION = 6;
    private static final int MIN_TIMESTAMP_PRECISION = 1;

    private static final int MAX_DECIMAL_PRECISION = 38;
    private static final int MIN_DECIMAL_PRECISION = 1;

    @Override
    public boolean canHandle(String url) {
        return url.startsWith("jdbc:impala:");
    }

    @Override
    public Optional<String> defaultDriverName() {
        return Optional.of("com.cloudera.impala.jdbc41.Driver");
    }

    @Override
    public String dialectName() {
        return "Impala";
    }

    @Override
    public int maxDecimalPrecision() {
        return MAX_DECIMAL_PRECISION;
    }

    @Override
    public int minDecimalPrecision() {
        return MIN_DECIMAL_PRECISION;
    }

    @Override
    public int maxTimestampPrecision() {
        return MAX_TIMESTAMP_PRECISION;
    }

    @Override
    public int minTimestampPrecision() {
        return MIN_TIMESTAMP_PRECISION;
    }
}
